<?php

/* ------------------------------------------
 * @AUTHOR: TANDAT @EMAIL:tidusvn05@gmail.com
 * @PHONE: +84933731173
 * ----------------------------------------- */

class D_Paging {
	static $default_page_range = 5;
	static $default_item_count_per_page = 15;
	
	// input config current_page && total
	static function init($config){
		$page_range = isset($config['page_range']) ? $config['page_range'] : D_Paging::$default_page_range;
		$item_count_per_page = isset($config['item_count_per_page']) ? $config['item_count_per_page'] : D_Paging::$default_item_count_per_page;
		$current_page = isset($config['current_page']) ? $config['current_page'] : 1;
		
		$paginator = Zend_Paginator::factory($config['total']);
		$paginator->setCurrentPageNumber($current_page);
		$paginator->setPageRange($page_range);
		$paginator->setItemCountPerPage($item_count_per_page); // lay theo so row moi trang
		return $paginator;
	}
}